﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.Model;
using University.Workshop.Business;
using University.Workshop.Presenters;

namespace University.Workshop.WinApp
{
	public partial class LoginInterface: Form, ILogOn
	{
        PresenterLogOn presenter;
        PrincipalForm father;

        public LoginInterface(PrincipalForm father)
		{
            presenter = new PresenterLogOn(this);
			InitializeComponent();
            this.father = father;
		}

        private void button1_Click(object sender, EventArgs e)
        {
            string message = presenter.Logged();
            MessageBox.Show(message);
            if (!message.Equals("El usuario no se encuentra registrado"))
            {
                father.LogIn(presenter.ObtainLoggedUser());
                this.Close();
            }
        }

        #region Miembros de Ilogin

        string ILogOn.UserName
        {
            get
            {
                return textBox1.Text;
            }
            set
            {
                textBox1.Text = value;
            }
        }

        string ILogOn.Password
        {
            get
            {
                return textBox2.Text;
            }
            set
            {
                textBox2.Text = value; ;
            }
        }

        #endregion

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void LoginInterface_Load(object sender, EventArgs e)
        {

        }
    }
}
